package modelLayer;
import java.util.ArrayList;

/**
 * Denne class omhandler Personer, og har deres navn, adresse, post nummer, by og telefon nr.
 * Disse variabler kan ændres
 *  
 * 
 */
public class DVD
{
    private String barcode;
    private String title;
    private String artist;
    private String publishDate;
    ArrayList<Copy> CopyList;
    
    /**
     * Constructor for objects of class Person
     */
    public DVD(String barcode, String title, String artist, String publishDate)
    {
        this.barcode = barcode;
        this.title = title;
        this.artist = artist;
        this.publishDate = publishDate;
        this.CopyList = new ArrayList<Copy>();
    }
    public DVD()
    {
        barcode = "57100154778";
        title = "Tarzan";
        artist = "Leonardo Dicaprio";
        publishDate = "10-12-1999";
    }
    public void printInformation(){
        System.out.println("barcode is: " + barcode);
        System.out.println("title is: " + title);
        System.out.println("Artist: " + artist);
        System.out.println("Date: " + publishDate);
    }
    
    public void removeCopy(Copy c)
    {
        CopyList.remove(c);
    }
    
    public void addCopy(Copy c)
    {
        CopyList.add(c);
    }
    
        public String getBarcode() {
        return barcode;
    }
    public void setBarcode(String barcode) {
        this.barcode = barcode;
    }
    public String getTitle() {
        return title;
    }
    public void setTitle(String title) {
        this.title = title;
    }
    public String getArtist() {
        return artist;
    }
    public void setArtist(String artist) {
        this.artist = artist;
    }
    public String getPublishDate() {
        return publishDate;
    }
    public void setPublishDate(String publishDate) {
        this.publishDate = publishDate;
    }
    
    public Copy findCopy(String serialNumber)
    {
        Copy copyToReturn = null;
        boolean found = false;
        int i = 0;
        while(!found && i < CopyList.size())
        {   
            Copy copy = CopyList.get(i);
            if(copy.getSerialNumber().equals(serialNumber))
            {
                copyToReturn = copy;
                found = true;
            }
            i++;
        }   
        return copyToReturn;
    }
}
